﻿/*
Navicat SQL Server Data Transfer

Source Server         : LOCALHOST
Source Server Version : 110000
Source Host           : .:1433
Source Database       : AAACHAM2
Source Schema         : dbo

Target Server Type    : SQL Server
Target Server Version : 110000
File Encoding         : 65001

Date: 2014-04-25 13:41:54
*/


-- ----------------------------
-- Table structure for tb0055
-- ----------------------------
DROP TABLE [dbo].[tb0055]
GO
CREATE TABLE [dbo].[tb0055] (
[ID] int IDENTITY(1,1) NOT NULL,
[WareHouseID] varchar(20) NOT NULL ,
[WareHouseName] nvarchar(100) NULL ,
[DivisionID] varchar(20) NOT NULL ,
[Address] nvarchar(250) NULL ,
[FullName] nvarchar(50) NULL ,
[IsTemp] tinyint NOT NULL DEFAULT ((0)) ,
[Disabled] tinyint NOT NULL DEFAULT ((0)) ,
[CreateDate] datetime NULL ,
[CreateUserID] varchar(20) NULL ,
[LastModifyDate] datetime NULL ,
[LastModifyUserID] varchar(20) NULL,
[GroupShow] varchar(150) NOT NULL DEFAULT ((''))
)


GO

-- ----------------------------
-- Records of tb0055
-- ----------------------------
INSERT INTO [dbo].[tb0055] ([WareHouseID], [WareHouseName], [DivisionID], [Address], [FullName], [IsTemp], [Disabled], [CreateDate], [CreateUserID], [LastModifyDate], [LastModifyUserID]) VALUES (N'KTONG', N'KHO TỔNG', N'HPCNB2013', N'', N'', N'0', N'0', N'2013-01-25 10:12:26.250', N'ADMIN', N'2013-01-25 10:12:26.250', N'ADMIN')
GO
GO
INSERT INTO [dbo].[tb0055] ([WareHouseID], [WareHouseName], [DivisionID], [Address], [FullName], [IsTemp], [Disabled], [CreateDate], [CreateUserID], [LastModifyDate], [LastModifyUserID]) VALUES (N'KLD', N'KHO SỈ LÂM ĐỒNG', N'HPCNB2013', N'', N'', N'0', N'0', N'2013-01-13 09:41:08.483', N'ADMIN', N'2013-12-03 21:42:35.540', N'kim')
GO
GO

-- ----------------------------
-- Indexes structure for table tb0055
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table tb0055
-- ----------------------------
ALTER TABLE [dbo].[tb0055] ADD PRIMARY KEY NONCLUSTERED ([WareHouseID])
GO

-- ----------------------------
-- Triggers structure for table tb0055
-- ----------------------------
--DROP TRIGGER [dbo].[AX1303]
GO
CREATE TRIGGER [dbo].[AX1303]
ON [dbo].[tb0055]
AFTER DELETE
AS

Declare		@Deleted_Cursor as cursor,
		@WareHouseID as varchar(20)

Set @Deleted_Cursor = CURSOR SCROLL KEYSET FOR
	Select WareHouseID 
	From Deleted
Open @Deleted_Cursor
Fetch next from @Deleted_Cursor into @WareHouseID
While @@Fetch_Status = 0
  Begin
	Delete From tb0065 Where WareHouseID = @WareHouseID
	Fetch next from @Deleted_Cursor into @WareHouseID
  End
Close @Deleted_Cursor

GO
